﻿using KINLO.Data.Reporitory;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace KINLO.UI.Main.View
{
    /// <summary>
    /// ModifyPass.xaml 的交互逻辑
    /// </summary>
    public partial class ModifyPass : Window
    {
        ConfigReporitory CDB = new ConfigReporitory();
        public ModifyPass()
        {
            InitializeComponent();
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }

        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            if ((pass1.Password != pass2.Password) && (string.IsNullOrEmpty(pass1.Password) || string.IsNullOrEmpty(pass2.Password)))
            {
                pass1.Password = "";
                pass2.Password = "";
                MessageBox.Show("密码不能为空或密码不一致，请重新输入", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            else
            {
               var len= CDB.UpdatePass(pass1.Password);
                if (len > 0)
                {
                    MessageBox.Show("保存成功");
                    this.Close();
                }
                else
                {
                    MessageBox.Show("保存失败");
                    pass1.Password = "";
                    pass2.Password = "";
                }
            }
        }
    }
}
